package la.iok.hzsvn.lewin.movie.core.model;

import java.util.Objects;

/**
 * 优惠券基类，包含通用信息
 */
public class CouponBase {
    /**
     * 折扣券
     */
    public static final Integer TYPE_PERCENT = 1;
    /**
     * 金额券
     */
    public static final Integer TYPE_AMOUNT = 2;
    /**
     * 优惠券名称
     */
    private String name;
    /**
     * 优惠券类型。1：折扣卷，2：金额卷
     */
    private Integer type;
    /**
     * 优惠卷额度。如果是折扣券,那就是百分比的值,如五折券,值为50，表示50%；如果有金额券,值为236,那就是优惠金额236分,单位为分
     */
    private Integer amount;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getType() {
        return type;
    }

    public void setType(Integer type) {
        this.type = type;
    }

    public Integer getAmount() {
        return amount;
    }

    public void setAmount(Integer amount) {
        this.amount = amount;
    }

    /**
     * 是否折扣券类型
     * @return 是折扣券类型返回true,否则false
     */
    public boolean typePercent(){
        return TYPE_PERCENT.equals(type);
    }

    /**
     * 是否金额券类型
     * @return 是金额券返回true,否则false
     */
    public boolean typeAmount(){
        return TYPE_AMOUNT.equals(type);
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof CouponBase)) return false;
        CouponBase that = (CouponBase) o;
        return Objects.equals(name, that.name) && Objects.equals(type, that.type) && Objects.equals(amount, that.amount);
    }

    @Override
    public int hashCode() {
        return Objects.hash(name, type, amount);
    }

    @Override
    public String toString() {
        return "CouponBase{" +
                "name='" + name + '\'' +
                ", type=" + type +
                ", amount=" + amount +
                '}';
    }
}
